package edu.uaskl.jqf.model.gates.util;

import edu.uaskl.jqf.model.Qubit;
import edu.uaskl.jqf.model.gates.interfaces.Gate;
import edu.uaskl.jqf.model.matrix.MatrixComplex;

public abstract class BaseGate implements Gate {

    /** Createss a quadratic gate with the row size from matrix and multiplies this gate with matrix */
    @Override
    public MatrixComplex multiply(final MatrixComplex matrix) {
        final int size = matrix.getRows();
        return getSize(size).multiply(matrix);
    }

    /** Creates a quadratic gate with size 2 and multiplies this gate with qubit */
    @Override
    public Qubit multiply(final Qubit qubit) {
        return getSize(2).multiply(qubit);
    }

    /** Creates a quadratic gate with size 2 and tensor this gate with matrix */
    @Override
    public MatrixComplex tensor(final MatrixComplex matrix) {
        return getSize(2).tensor(matrix);
    }
}
